//路由懒加载的封装
import React, {lazy} from 'react'


const LazyLoadIcon: React.FC<{ name: string }> = ({name}) => {

  const lazyLoadIcon = (name: string): React.ReactNode => {
    return <React.Suspense fallback={<span>加载中....</span>}>
      {React.createElement(lazy(() => import('@ant-design/icons').then(module => {
        return {
          default: (module as any)[name],
        };
      })), {})}
    </React.Suspense>
  }

  return (
    <>
      {lazyLoadIcon(name)}
    </>
  )
}

export default LazyLoadIcon
